//
//  DiscoveryViewController.swift
//  WeiBo2017
//
//  Created by 王璐 on 2017/4/12.
//  Copyright © 2017年 wl. All rights reserved.
//

import UIKit

/// cell的可重用标识符
fileprivate let WLDiscoveryCellID = "DiscoveryCellID"

class DiscoveryViewController: RooterViewController {

    override func viewDidLoad() {
        setupRefreshControl()
        
        super.viewDidLoad()

        tableView?.register(UITableViewCell.self, forCellReuseIdentifier: WLDiscoveryCellID)
        
        vistorView?.setUpInfo(imageName: "visitordiscover_image_message",
                              message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
    }

    override func loadData() {
        
        refreshControl?.beginRefreshing()
//        DispatchQueue.asyncAfter(DispatchQueue.main)
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+2) { 
            self.dataCount += 10
            self.tableView?.reloadData()
            self.refreshControl?.endRefreshing()
//            self.pullUpView.stopAnimating()
        }
    }
    
    fileprivate var dataCount = 0

}

// MARK: - 数据源方法
extension DiscoveryViewController{

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataCount
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: WLDiscoveryCellID, for: indexPath)
        cell.textLabel?.text = "\(indexPath.row)"
        return cell
    }
    
}
